/**
 * Created by ljg on 2017/3/27.
 */
import './style.css'
const uiTable=function () {
    angular.module('ui.table')
        .directive('uiSearchForm', function (eventHelper) {
            return {
                restrict: 'E',
                replace: true,
                transclude: true,
                controller:function ($scope,$attrs) {

                },
                scope:{},
                require:"^?uiContainer",
                template: function(el,attr){
                    return '<div class="panel-heading table-button-panel">'+
                                '<div class="row">' +
                                    '<div class="col-md-10 table-search-form">' +
                                         '<form id={{searchFormKey}}>' +
                                                '<ng-transclude></ng-transclude>'+
                                         '</form>' +
                                    '</div>'+
                                    '<div class="col-md-2">' +
                                            '<button type="button" class="btn btn-sm btn-primary" ng-click="_getData({})">查询</button>' +
                                    '</div>'+
                                '</div>'+
                            '</div>';
                },
                link : function(scope, element, attrs,ctrl) {
                    scope.searchFormKey='table_form_'+ctrl.key;
                    scope._getData=function (param) {
                        ctrl._queryData(param);
                    }
                    $(element).bind("keyup",function (event) {
                        if(event.key==="Enter"){

                            ctrl._queryData({});
                        }
                    })
                },
            };
        });
}
export default uiTable;
